package com.sanpu.kxe.business.trade.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sanpu.kxe.R;
import com.sanpu.kxe.business.trade.bean.MyRebTotalOutput;

import java.util.ArrayList;

/**
 * Description：我的返佣列表
 * Created by 薛勇军 on 2018/8/8.
 */

public class RebTotalAdapter extends BaseQuickAdapter<MyRebTotalOutput, BaseViewHolder> {
//        implements StickyRecyclerHeadersAdapter<BaseViewHolder> {

//    private LayoutInflater inflater;

    public RebTotalAdapter() {
        super(R.layout.item_reb_total, new ArrayList<MyRebTotalOutput>());
//        inflater = LayoutInflater.from(context);
    }

    @Override
    protected void convert(BaseViewHolder helper, MyRebTotalOutput item) {
        if (item != null) {
            helper.setText(R.id.type, TextUtils.isEmpty(item.getRebateType()) ? "-" : item.getRebateType())
                    .setText(R.id.reb, item.getRebateAmount() == null ? "0" : item.getRebateAmount())
                    .setText(R.id.time, TextUtils.isEmpty(item.getRebateTime()) ? "-" : item.getRebateTime())
                    .setText(R.id.name, item.getTradeUserName());

            TextView vAmount = helper.getView(R.id.amount);
            if (!TextUtils.isEmpty(item.getPayAmount())) {
                vAmount.setText("消费金额:￥" + item.getPayAmount()+"");
                vAmount.setVisibility(View.VISIBLE);
            } else {
                vAmount.setVisibility(View.GONE);
            }

        }
    }

//    @Override
//    public long getHeaderId(int position) {
//        MyRebTotalOutput output = getItem(position);
//        if (output == null) return -1;
//        String time = output.getRebateTime();
//        if (TextUtils.isEmpty(time) || time.length() < 8) return 0;
//        Date date = DateUtils.string2Date(time.substring(0, 7), "yyyy-MM");
//        return date.getTime();
//    }

//    @Override
//    public BaseViewHolder onCreateHeaderViewHolder(ViewGroup parent) {
//        return new BaseViewHolder(inflater.inflate(R.layout.item_rebtotal_head, parent, false));
//    }
//
//    @Override
//    public void onBindHeaderViewHolder(BaseViewHolder holder, int position) {
//        MyRebTotalOutput output = getItem(position);
//        if (output != null && output.getRebateTime() != null && output.getRebateTime().length()>7) {
//            holder.setText(R.id.month, output.getRebateTime().substring(0,7));
//        }
//    }
}
